DBE Structure

It appears to me that DBE's are DXL Objects. Therefore, I'm very interested if anyone has been able to publish the structure of the DXL Object for the DBE. I'm most interested in finding out how to read the label of a DBE.


Doug.Zawacki - Thu Jan 16 14:43:09 EST 2014

Re: DBE Structure
pommCannelle - Fri Jan 17 08:09:45 EST 2014

according to Master Mamsch, DxlObjects are equals to Skip list ( https://www.ibm.com/developerworks/community/forums/html/topic?id=7dfbdc51-07ca-4409-8a77-edbd50ba962a )

So i've tried to convert a DBE in Skip list in order to be abble to read his fields ...

Skip skipOf ( DBE this ) { return ( Skip addr_ this ) }

DB essai = topMost "essai"
DBE lab = label ( essai, "test" )
DBE info = text ( essai, "", "", 350, true )

void doTest(DB x) {
    Skip rez = skipOf ( lab )
    string property = ""; string propertyName = ""
    string binfo = ""
    for property in rez do {
        propertyName = ( string key rez )
        binfo = binfo "\n" propertyName "\n"
    }
    binfo = binfo "\n" "done!"
    set ( info, binfo )
}
apply ( essai, "try it", doTest )
show essai

Seem's DBE is not a DxlObject after all ?? ;)

Re: DBE Structure
Mathias Mamsch - Fri Jan 17 17:29:12 EST 2014

A DBE is not a DxlObject(=Skip list). I assume with DXL Object you mean it has some internal structure. Yes it has, just like any other DXL data type.

However I do not understand what you mean by "read the label of a DBE"? To get the contents of a DBE there is a get function. There are several tricks to read stuff from the GUI where there is no get function available, e.g. the title of a column in a listview. I am pretty sure you neither need nor want to use the DBE internal structure for doing anything on your GUI.

The only useful thing I ever got from the internal structure of a DB was the current DXL context pointer (which the GUI stores to know in what DXL context it is executed). However I did not investigate a lot further. As you can imagine GUI elements are complex objects. They have a type, diverse handlers, callback pointers, configuration data, etc, etc.

So what do you want to do with that information? Regards, Mathias

Re: DBE Structure
Doug.Zawacki - Mon Jan 20 10:16:28 EST 2014

Mathias Mamsch - Fri Jan 17 17:29:12 EST 2014

A DBE is not a DxlObject(=Skip list). I assume with DXL Object you mean it has some internal structure. Yes it has, just like any other DXL data type.

However I do not understand what you mean by "read the label of a DBE"? To get the contents of a DBE there is a get function. There are several tricks to read stuff from the GUI where there is no get function available, e.g. the title of a column in a listview. I am pretty sure you neither need nor want to use the DBE internal structure for doing anything on your GUI.

The only useful thing I ever got from the internal structure of a DB was the current DXL context pointer (which the GUI stores to know in what DXL context it is executed). However I did not investigate a lot further. As you can imagine GUI elements are complex objects. They have a type, diverse handlers, callback pointers, configuration data, etc, etc.

So what do you want to do with that information? Regards, Mathias

Hi,

What I mean to say is that the syntax for accessing some DBE elements isidentical to using a DXL Object. ie.

myObject->"top"

Therefore, I assumed a DBE was declared as a DXL Object. My only objective is trying to get the "Label".  For Example:

DBE zip = field(fieldBox, " Zipcode: ", "", 12)  declares a field DBE. If that field is blank I would like to display a mesage saying the "Zipcode" field cannot be blank by displaying the label of the DBE...the label is declared as "Zipcode"

I hope this is a bit more clear. 

Re: DBE Structure
GregM_dxler - Mon Jan 20 10:42:20 EST 2014

Doug.Zawacki - Mon Jan 20 10:16:28 EST 2014

Hi,

What I mean to say is that the syntax for accessing some DBE elements isidentical to using a DXL Object. ie.

myObject->"top"

Therefore, I assumed a DBE was declared as a DXL Object. My only objective is trying to get the "Label".  For Example:

DBE zip = field(fieldBox, " Zipcode: ", "", 12)  declares a field DBE. If that field is blank I would like to display a mesage saying the "Zipcode" field cannot be blank by displaying the label of the DBE...the label is declared as "Zipcode"

I hope this is a bit more clear. 

It might be possible, but I find that is a little like making a bitmap of a object and then trying to decode the bitmap to get the object back.

Why don't you declare a variable

string Zipcode_Label = "Zipcode: "

and then when declaring the zip element, you use the string

DBE zip = field(fieldBox, Zipcode_Label,"",12)

When you want to make a message, then you can also just use the variable Zipcode_label with it.

ack Zipcode_Label " can not be blank!"

Hope this helps,

Greg

Re: DBE Structure
Doug.Zawacki - Mon Jan 20 13:23:55 EST 2014

GregM_dxler - Mon Jan 20 10:42:20 EST 2014

It might be possible, but I find that is a little like making a bitmap of a object and then trying to decode the bitmap to get the object back.

Why don't you declare a variable

string Zipcode_Label = "Zipcode: "

and then when declaring the zip element, you use the string

DBE zip = field(fieldBox, Zipcode_Label,"",12)

When you want to make a message, then you can also just use the variable Zipcode_label with it.

ack Zipcode_Label " can not be blank!"

Hope this helps,

Greg

I could do that Greg but that means I would have to have an ack statement for each field I want to check.

Let me try to explain a little further.

For example If I have two fields

1. Source Fileaname

2. Destination Filename

I want to write some generic code to verify that the folder paths exist in both fields. But, I do not want to have to specify the "label" of each field. My generic code may look like:

ack "The " dbe.label  " folder path does not exist"

 

Re: DBE Structure
Mathias Mamsch - Mon Jan 20 16:13:45 EST 2014

Doug.Zawacki - Mon Jan 20 10:16:28 EST 2014

Hi,

What I mean to say is that the syntax for accessing some DBE elements isidentical to using a DXL Object. ie.

myObject->"top"

Therefore, I assumed a DBE was declared as a DXL Object. My only objective is trying to get the "Label".  For Example:

DBE zip = field(fieldBox, " Zipcode: ", "", 12)  declares a field DBE. If that field is blank I would like to display a mesage saying the "Zipcode" field cannot be blank by displaying the label of the DBE...the label is declared as "Zipcode"

I hope this is a bit more clear. 

Ok, I see where the confusion comes from... What you need to understand is, that in DXL the "->" is an operator like every other operator and may be overridden by any custom code. So although DxlObject has the -> syntax (just like links) this has nothing to do with accessing a DxlObject. It is just a syntax, that the DXL creators thought would make sense.

You can achieve your objective by hooking the DBE creation functions and store the labels in a skip list. This can be done from an include without the need to make modifications to existing code.

// **** DBELabels.inc  - include in any GUI program *********

// Basic API to save and get Labels from DBE fields
Skip gskDBELabels = create();
void saveLabel(DBE f, string sLabel) { put(gskDBELabels, f, sLabel); }
string getLabel (DBE f) { string s= "Unknown"; find (gskDBELabels, f, s); return s}

// backup the old field functions for using them in hooks
DBE field_old (DB a, string b, string c, int d) { return field(a,b,c,d); }
DBE field_old (DB a, string b, string c, int d, bool e) { return field(a,b,c,d,e); }

// DBE field hooks for storing labels
DBE field (DB a, string b, string c, int d) { DBE r=field_old(a,b,c,d); saveLabel(r,b); return r }
DBE field (DB a, string b, string c, int d, bool e) { DBE r=field_old(a,b,c,d,e); saveLabel(r,b); return r }

// Hook the other DBE field constructors here too for a general library ...

// ****** SNIP your Gui Program .... uses the new getLabel function ...

DB db = topMost "A Test"
DBE lab = field ( db, "Test 1" , "", 20) 
DBE info = field ( db, "Test 2", "", 20, false )

void callback (DB x) { 
    string sMsg = (getLabel lab) ": " ((get lab) string) "\n"
    infoBox sMsg (getLabel info) ": " ((get info) string) "\n"
}

apply(db, "Show Message", callback);

show db

Hope this helps, regards, Mathias

Re: DBE Structure
Doug.Zawacki - Mon Jan 20 16:34:35 EST 2014

Mathias Mamsch - Mon Jan 20 16:13:45 EST 2014

Ok, I see where the confusion comes from... What you need to understand is, that in DXL the "->" is an operator like every other operator and may be overridden by any custom code. So although DxlObject has the -> syntax (just like links) this has nothing to do with accessing a DxlObject. It is just a syntax, that the DXL creators thought would make sense.

You can achieve your objective by hooking the DBE creation functions and store the labels in a skip list. This can be done from an include without the need to make modifications to existing code.

// **** DBELabels.inc  - include in any GUI program *********

// Basic API to save and get Labels from DBE fields
Skip gskDBELabels = create();
void saveLabel(DBE f, string sLabel) { put(gskDBELabels, f, sLabel); }
string getLabel (DBE f) { string s= "Unknown"; find (gskDBELabels, f, s); return s}

// backup the old field functions for using them in hooks
DBE field_old (DB a, string b, string c, int d) { return field(a,b,c,d); }
DBE field_old (DB a, string b, string c, int d, bool e) { return field(a,b,c,d,e); }

// DBE field hooks for storing labels
DBE field (DB a, string b, string c, int d) { DBE r=field_old(a,b,c,d); saveLabel(r,b); return r }
DBE field (DB a, string b, string c, int d, bool e) { DBE r=field_old(a,b,c,d,e); saveLabel(r,b); return r }

// Hook the other DBE field constructors here too for a general library ...

// ****** SNIP your Gui Program .... uses the new getLabel function ...

DB db = topMost "A Test"
DBE lab = field ( db, "Test 1" , "", 20) 
DBE info = field ( db, "Test 2", "", 20, false )

void callback (DB x) { 
    string sMsg = (getLabel lab) ": " ((get lab) string) "\n"
    infoBox sMsg (getLabel info) ": " ((get info) string) "\n"
}

apply(db, "Show Message", callback);

show db

Hope this helps, regards, Mathias

Yes Mathias,

My bad assumption. I guess I had just hoped it really was a DXLObject. Thanks, for the code snippet to acheive my goal. I appreciates everybodys contribution to this thread.